<?php

use App\Models\Department;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\DB;

Admin::routes();

Route::group([
    'prefix'        => config('admin.route.prefix'),
    'namespace'     => config('admin.route.namespace'),
    'middleware'    => config('admin.route.middleware'),
    'as'            => config('admin.route.prefix') . '.',
], function (Router $router) {

    # 默认进入数据报表
    $router->get('/', 'StatController@call_single')->name('home');

    /**
     * 线索
     */
    $router->resource('/clue','ClueController');                # 线索 ok
    $router->resource('/records','RecordsController');          # 跟进记录
    $router->resource('/assets','AssetsController');            # 客户资产
    $router->resource('/files','ClientFileController');         # 客户文件
    $router->resource('/needHelp','NeedHelpController');        # 协助记录

    $router->resource('dial','DialController');                 # 呼叫记录

    /**
     * 客户
     */
    $router->resource('/clients','ClientController');
    $router->resource('/records','RecordsController');          # 跟进记录
    $router->resource('/assets','AssetsController');            # 客户资产
    $router->resource('/files','ClientFileController');         # 客户文件
    $router->resource('/needHelp','NeedHelpController');        # 协助记录
    $router->resource('/moneyOut','MoneyOutController');         # 贷款管理
    $router->resource('/feedback','FeedBackController');        # 回访

    $router->resource('moneyOutCheck','MoneyOutCheckController');       # 客户成交审核


    // 单独的
    $router->post('/records2','RecordsController@store2')->name('records2');

    # 系统设置
    $router->resource('crmConfig','CrmConfigController');      # 数据字典
    $router->resource('syslog','SysLogController');             # 操作日志

    # 客户管理

#    $router->resource('/allClient','AllClientController');      # 全部客户
    $router->resource('/sea','SeaController');                  # 公海

    # 客户线索

    $router->resource('/threepart','ThreePartController');


    $router->put('/roles/update/{id}','RoleController@updateForView');
    $router->resource('roles','RoleController');
    $router->resource('permissions','PermissionController');
    $router->resource('users','UserController');


    # 业绩管理
    $router->resource('/mission','MissionController');

    # 部门管理
    $router->resource('/department','DepartmentController');
//    $router->resource('/myDepartment','MyDepartmentController');

    # 贷款审核


//    $router->resource('myMoneyOut','MyMoneyOutController');             # 我的贷款

    # 回访
#    $router->resource('/myFeedBack','MyFeedBackController');

    # 导入数据
    $router->any('/cardnewsimport', 'SeaController@import');

    # 数据统计
    $router->resource('stat','StatController');
    // 呼叫次数排行
    $router->get('stat/call/single' , 'StatController@call_single')->name('stat.call.single');
    $router->get('stat/call/department' , 'StatController@call_department')->name('stat.call.department');
    // 跟进次数排行
    $router->get('stat/follow/single' , 'StatController@follow_single')->name('stat.follow.single');
    $router->get('stat/follow/department' , 'StatController@follow_department')->name('stat.follow.department');
    // 跟进次数排行
    $router->get('stat/clients/single' , 'StatController@clients_single')->name('stat.clients.single');
    $router->get('stat/clients/department' , 'StatController@clients_department')->name('stat.clients.department');
    // 跟进次数排行
    $router->get('stat/follow/single' , 'StatController@follow_single')->name('stat.follow.single');
    $router->get('stat/follow/department' , 'StatController@follow_department')->name('stat.follow.department');

    // 放贷金额排行
    $router->get('stat/amount/single' , 'StatController@amount_single')->name('stat.amount.single');
    $router->get('stat/amount/department' , 'StatController@amount_department')->name('stat.amount.department');

    // 客户金额排行
    $router->get('stat/amount/client','StatController@amount_client')->name('stat.amount.client');

    // 个人分系
    $router->get('stat/status/single','StatController@status_single')->name('stat.status.single');
    $router->get('stat/status/department','StatController@status_department')->name('stat.status.department');
    $router->resource('/checkRepeat','checkRepeatController');
    # 清空缓存
    $router->get('/refreshRedis','CrmConfigController@refreshRedis');

    # 拨号
    $router->get('dial/call/{id}','DialController@dial');

    # 测试
    $router->any('/test','SeaController@test');

    // 三级联动
    $router->get('/getDepartment/q/{q}','DepartmentController@getDepartment');
});
